<html>
<head>
<title>Upload File</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">Pilih File : <input type="file" name="fl" /><input type="submit" value="Upload" name="submit"/></form>
<?php 
if(isset($_POST['submit']) and isset($_FILES['fl'])){
	//lokasi direktori upload
	$dir='./upload';
	$file = $_FILES['fl']['tmp_name'];
	$name = $_FILES['fl']['name'];
	$info = pathinfo($name);
	//memastikan file tidak kosong

	//menetapkan data max file upload
		if(filesize($file)>200000){
		echo "ukuran terlalu besar";
		exit('file terlalu besar maksimum 200kb');
		}
	//menetapkan tipe file
		if($info['extension'] == 'pdf' || $info['extension']=='zip'){
		echo "tipe file pdf atau zip";
		}else {
		exit ('maaf hanya file pdf atau zip');
		}
		if (!move_uploaded_file($file,$dir.$name)){
		echo "unable to upload file";
		}else{
		echo "file uploaded..";
		}
}
?>
</body>
</html>